<?php
@$sjid=$_REQUEST['sjid'];
if(!empty($sjid)){
    $pdo=new PDO('mysql:dbname=shuju;charset=utf8','root');
    $use=$pdo->prepare('delete from emshoujian where id=:id');
    $ok=$use->execute(array('id'=>$sjid));
}

@$fjid=$_REQUEST['fjid'];
if(!empty($fjid)){
    $pdo=new PDO('mysql:dbname=shuju;charset=utf8','root');
    $use=$pdo->prepare('delete from emfajian where id=:id');
    $ok=$use->execute(array('id'=>$fjid));
}
session_start();
@$admin=$_SESSION["ZHe"];
@$sendwho=$_REQUEST['sendname'];@$title=$_REQUEST['sendtitle'];@$neirong=$_REQUEST['sendneirong'];
@$fasong=$_REQUEST['fasong'];
if($fasong=='fasong'){
//自己备份
    $pdo=new PDO('mysql:dbname=shuju;charset=utf8','root');
    $use=$pdo->prepare('select * from yuangong where admin=:admin');
    $use->execute(array('admin'=>$admin));
    $data=$use->fetchAll(PDO::FETCH_NAMED);
        $ygid=@$data[0][id];
    /*获取当前时间*/
    $shijian=$pdo->prepare('select now()');
    $shijian->execute();
    $timehq=$shijian->fetchAll(PDO::FETCH_NAMED);
    $time=$timehq[0]['now()'];
    /*获取当前时间*/
    $send=$pdo->prepare('insert into emfajian(ygid,title,neirong,sendwho,sendTime) values(:a1,:a2,:a3,:a4,:a5);');
    $send->execute(array('a1'=>$ygid,'a2'=>$title,'a3'=>$neirong,'a4'=>$sendwho,'a5'=>$time));

//发送
    $use111=$pdo->prepare('select * from einfor where ygid=:ygid');
    $use111->execute(array('ygid'=>$ygid));
    $data111=$use111->fetchAll(PDO::FETCH_NAMED);
    $jijianName=$admin.'/'.$data111[0][name];

    $pdo=new PDO('mysql:dbname=shuju;charset=utf8','root');
    $use11=$pdo->prepare('select * from customerLogin where adm=:aa');
    $use11->execute(array('aa'=>$sendwho));
    $data11=$use11->fetchAll(PDO::FETCH_NAMED);
    if(!empty($data11)){
        $send11=$pdo->prepare('insert into ctmXiaoxi(loginId,title,neirong,who,reciveTime) values(:b1,:b2,:b3,:b4,:b5);');
        $send11->execute(array('b1'=>@$data11[0][id],'b2'=>$title,'b3'=>$neirong,'b4'=>$jijianName,'b5'=>$time));
    }
    $use12=$pdo->prepare('select * from yuangong where admin=:bb');
    $use12->execute(array('bb'=>$sendwho));
    $data12=$use12->fetchAll(PDO::FETCH_NAMED);
    if(!empty($data12)){
        $send12=$pdo->prepare('insert into emshoujian(ygid,title,neirong,who,reciveTime) values(:b1,:b2,:b3,:b4,:b5);');
        $send12->execute(array('b1'=>@$data12[0][id],'b2'=>$title,'b3'=>$neirong,'b4'=>$jijianName,'b5'=>$time));
    }

    header('Location:emain.php');
}

?>